<?

session_start();

require('config_take.php');
require('include_take.php' );
require('include_jobs.php');
/*
$link = mysql_connect( $db_host, $db_user, $db_password );
mysql_select_db( $db_name );
$result = mysql_query( 'set character set utf8' );
*/

$title = $site_name;

require('header.php');
?>
<h1><?= $site_name ?></h1>
<h2>猫の手孫の手お助けサイト</h2>
<? require('topbar.php') ?>
<?
$q = '%'. $_GET['query'] .'%';
$st = $db->prepare('select * from jobs where'.
                   ' worktext like :q or'.
                   ' licence  like :q or'.
                   ' area     like :q or'.
                   ' fee      like :q');
$st->bindParam(':q', $q, PDO::PARAM_STR);
if($st->execute()) $jobs = $st->fetchAll(PDO::FETCH_OBJ);
if($jobs) print_jobs($db, $jobs, $_SESSION['memberid']);

/*
if ( $_GET['query'] != '' ) $where .= "worktext like '%" . mysql_real_escape_string( $_GET['query'] ) . "%'";

$sql = "select * from jobs where (worktext like '%" . mysql_real_escape_string( $_GET['query'] ) . "%') or (licence like '%" . mysql_real_escape_string( $_GET['query'] ) . "%') or (fee like '%" . mysql_real_escape_string( $_GET['query'] ) . "%') or (area like '%" . mysql_real_escape_string( $_GET['query'] ) . "%')";

$result = mysql_query( $sql );
$num_rows = mysql_num_rows( $result );

echo $sql;
*/
?>
<? if ( $_GET['page'] >= $_GET['rows'] ) { ?>
<a href="result.php?page=<?= $_GET['page'] - $_GET['rows'] ?>&rows=<?= $_GET['rows'] ?>&author_id=<?= $_GET['author_id'] ?>&category_id=<?= $_GET['category_id'] ?>&query=<?= $_GET['query'] ?>&sort=<?= $_GET['sort'] ?>">前のページ&nbsp;</a>
<? } ?>
<?
require('footer.php');
